/**
 * @license
 * Copyright 2024 The Model Explorer Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ==============================================================================
 */

*:not(mat-icon) {
  /* stylelint-disable-next-line declaration-no-important -- override MDC */
  font-family: 'Google Sans Text', Arial, Helvetica, sans-serif !important;
  /* stylelint-disable-next-line declaration-no-important -- override MDC */
  letter-spacing: normal !important;
}

.title-container {
  position: relative;
  color: var(--me-on-surface-color);
  background-color: var(--me-surface-container-high-color);
  margin-bottom: 0;
}

.title {
  font-size: 24px;
  font-weight: 500;
  margin-top: -30px;
}

.description {
  line-height: 14px;
  font-size: 12px;
  color: var(--me-on-surface-variant-color);
  margin-top: 6px;
  margin-bottom: 4px;
  font-weight: normal;
}

.btns-container {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background-color: var(--me-surface-container-high-color);

  button {
    background-color: var(--me-secondary-container-color);
    color: var(--me-on-secondary-container-color);

    &.close {
      height: 30px;
      background-color: var(--me-primary-color);
      color: var(--me-on-primary-color);
    }
  }
}

.action-button {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;

  mat-icon {
    margin-right: 2px;
  }
}

.import-rules-input {
  display: none;
}

.dialog-content {
  padding: 0;
  box-sizing: border-box;
  background-color: var(--me-surface-container-low-color);
  overflow: hidden auto;
  color: var(--me-on-surface-color);

  .no-rules-message {
    padding: 12px 24px;
    font-size: 12px;
    color: var(--me-on-surface-variant-color);
  }
}

.common-input {
  padding: 0 4px;
  border: 1px solid var(--me-outline-variant-color);
  border-radius: 4px;
  height: 22px;
  box-sizing: border-box;
  outline: none;

  &:focus {
    border-color: var(--me-primary-color);
    outline: 1px solid var(--me-primary-color);
  }
}

.rules-table {
  width: 100%;
  font-size: 12px;

  th:not(.action-btns),
  td:not(.action-btns) {
    border-right: 1px solid var(--me-outline-hairline-variant-color);
  }

  tr td {
    border-bottom: 1px solid var(--me-outline-hairline-variant-color);
  }

  thead {
    text-align: left;
    height: 32px;
    position: sticky;
    top: 0;
    color: var(--me-on-surface-variant-color);
    background-color: var(--me-surface-container-color);
    z-index: 100;

    th {
      font-weight: 500;
      border-bottom: 1px solid var(--me-outline-hairline-variant-color);

      &.query {
        padding-left: 24px;
        width: 410px;

        .query-header-container {
          display: flex;
          align-items: center;

          .icon-container {
            width: 16px;
            height: 16px;
            opacity: 0.85;
            cursor: pointer;
            margin-left: 4px;
            color: var(--me-on-surface-variant-color);

            &:hover {
              opacity: 1;
            }

            mat-icon {
              font-size: 16px;
              width: 16px;
              height: 16px;
            }
          }
        }
      }

      &.target {
        padding-left: 12px;
      }

      &.styles {
        padding-left: 12px;
        min-width: 254px;
      }
    }
  }

  tbody {
    td {
      padding-top: 8px;
      padding-bottom: 8px;

      &.query {
        padding-left: 24px;
        padding-right: 12px;
        vertical-align: top;

        .node-list-viewers-container {
          display: flex;
          gap: 12px;
        }

        .node-list-viewer-container {
          display: flex;
          flex-direction: column;
          width: fit-content;
          margin-top: 12px;

          .label {
            line-height: 18px;
          }
        }
      }

      &.target {
        vertical-align: top;
        padding-left: 12px;
        padding-right: 12px;
      }

      &.styles {
        padding-left: 12px;
        padding-right: 18px;
        vertical-align: top;

        .styles-container {
          display: flex;
          flex-direction: column;
          gap: 2px;
        }
      }

      &.action-btns {
        vertical-align: top;
        padding-right: 12px;
        width: 80px;

        .action-buttons-container {
          display: flex;
          justify-content: flex-end;
          gap: 2px;
          color: var(--me-on-surface-variant-color);
        }

        .icon-container {
          display: flex;
          opacity: .7;
          cursor: pointer;
          margin-top: 2px;

          &:hover {
            opacity: .9;
          }

          mat-icon {
            font-size: 16px;
            width: 16px;
            height: 16px;
          }
        }
      }
    }

    .color-style-container {
      display: flex;
      align-items: center;

      .style-name-container {
        display: flex;
        align-items: center;
        cursor: pointer;
        user-select: none;
        width: 100px;

        input {
          cursor: pointer;
        }
      }

      .color-picker-container {
        display: flex;
        align-items: center;
        overflow: hidden;
        border-radius: 4px;
        border: 1px solid var(--me-outline-variant-color);
        margin-left: 4px;
        width: fit-content;
        box-sizing: border-box;
        height: 24px;
        position: relative;

        &:focus-within {
          border-color: var(--me-primary-color);
          outline: 1px solid var(--me-primary-color);
        }

        label {
          display: inline-block;
          width: 16px;
          height: 16px;
          margin: 2px;
          background-color: var(--me-error-text-color);
          border-radius: 4px;
          cursor: pointer;
          border: 1px solid var(--me-outline-variant-color);

          input {
            visibility: hidden;
          }
        }

        input[type='text'] {
          width: 100px;
          border: none;
          height: 100%;
          // background-color: transparent;
          outline: none;
        }
      }

      .number-editor-container {
        display: flex;
        align-items: center;
        overflow: hidden;
        margin-left: 4px;
        width: fit-content;

        input {
          width: 80px;
          height: 28px;
          border: 1px solid var(--me-outline-variant-color);
          border-radius: 4px;
          background-color: transparent;
          box-sizing: border-box;
          padding: 0 4px;
          outline: none;
        }
      }
    }
  }
}
